package ifmo.compiler.task21.parser;

import ifmo.compiler.task21.parser.symbols.Symbol;

public class Production {
	private boolean _hasRule = false;
	private Symbol _head;
	
	private Symbol[] _tail;
	
	public Production()
	{
	}

	public Production(Symbol head, Symbol[] tail)
	{
		_head = head;
		_tail = tail;
	}
	
	public Production(Symbol head, Symbol[] tail, boolean hasRule)
	{
		_head = head;
		_tail = tail;
		_hasRule = hasRule;
	}
	
	public Symbol getHead()
	{
		return _head;
	}
	
	public void setHead(Symbol head)
	{
		_head = head;
	}
	
	public Symbol[] getTail()
	{
		return _tail;
	}
	
	public void setTail(Symbol[] tail)
	{
		_tail = tail;	
	}
	
	public String toString()
	{
		String res = "";
		if (_head != null && _tail != null)
		{
			res = _head.toString() + "->";
			for (Symbol a : _tail)
			{
				res += "{" + a.toString() + "}";
			}
		}
		
		return res;
	}
	
	public boolean hasRule()
	{
		return _hasRule;
	}
	
	public void setHasRule(boolean value)
	{
		_hasRule = value;
	}
}
